// pages/musiclist/musiclist.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    musicList:[],
    musicInfo:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options);
    wx.showLoading({
      title: '加载中',
    })
    wx.cloud.callFunction({
      name:'music',
      data:{
        playlistId:options.playlistId,
        $url:'musiclist'
      }
    }).then((res) => {
      const pl = res.result.playlist
      this.setData({
        musicList:pl.tracks,
        musicInfo:{
          coverImgUrl: pl.coverImgUrl,
          name: pl.name,
        }
      })
      this.setMusicList()
      wx.hideLoading()
      console.log(pl.tracks);
    })
  },

  setMusicList(){
    wx.setStorageSync('musiclist', this.data.musicList)
  }
})